package com.bolt.support.base.service;

import com.bolt.convention.data.PageInfo;
import com.bolt.convention.data.Record;
import com.bolt.support.query.nativequery.parall.ParallelQuery;
import com.bolt.support.query.nativequery.parall.ParallelQueryConfig;
import com.bolt.support.query.nativequery.parall.ParallelQueryResult;
import org.springframework.data.domain.Pageable;

import java.util.List;

public interface INativeQuery {

    /**
     * 基于Native SQL和分页(不含排序，排序直接在native sql中定义)对象查询数据集合
     *
     * @param sqlId    Native SQL(自行组装好动态条件和排序的原生SQL语句，不含order by部分)
     * @param pageable 分页(不含排序，排序直接在native sql中定义)对象
     * @return Map结构的集合分页对象
     */
    <S> PageInfo<S> nativeQueryPage(String sqlId, Pageable pageable, Object parameterObject, Class<S> returnClass);

    PageInfo<Record> nativeQueryPage(String sqlId, Pageable pageable, Object parameterObject);

    <S> List<S> nativeQueryList(String sqlId, Object parameterObject, Class<S> returnClass);

    List<Record> nativeQueryList(String sqlId, Object parameterObject);

    <S> List<S> nativeQueryLimit(String sqlId, Object parameterObject, int limit, Class<S> returnClass);

    List<Record> nativeQueryLimit(String sqlId, Object parameterObject, int limit);


    <S> List<S> nativeQueryLimit(String sqlId, Object parameterObject, Pageable pageable, Class<S> returnClass);

    List<Record> nativeQueryLimit(String sqlId, Object parameterObject,Pageable pageable);

    <S> S nativeQueryOne(String sqlId, Object parameterObject, Class<S> returnClass);


    /**
     * 执行SQL
     *
     * @param sqlId
     * @param parameterObject
     * @return
     */
    int executeSql(String sqlId, Object parameterObject);

    List<ParallelQueryResult> parallelNativeQuery(List<ParallelQuery> parallelQueries, ParallelQueryConfig parallelConfig);
}